/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amuthu.expression.function;

import org.amuthu.expression.function.indicator.LagFunction;
import org.amuthu.expression.function.math.ExponentialFunction;
import org.amuthu.expression.function.math.AbsFunction;
import org.amuthu.expression.function.math.CosineFunction;
import org.amuthu.expression.function.math.LogarithmFunction;
import org.amuthu.expression.function.math.RandomFunction;
import org.amuthu.expression.function.math.SineFunction;
import org.amuthu.expression.function.math.SqrtFunction;
import java.util.HashMap;
import org.amuthu.expression.function.indicator.AdFunction;
import org.amuthu.expression.function.indicator.AroonDownFunction;
import org.amuthu.expression.function.indicator.AroonUpFunction;
import org.amuthu.expression.function.indicator.AtrFunction;
import org.amuthu.expression.function.indicator.AverageDirectionalIndexFunction;
import org.amuthu.expression.function.indicator.BollingerLowerFunction;
import org.amuthu.expression.function.indicator.BollingerMiddleFunction;
import org.amuthu.expression.function.indicator.BollingerUpperFunction;
import org.amuthu.expression.function.indicator.CommodityChannelIndexFunction;
import org.amuthu.expression.function.indicator.EmaFunction;
import org.amuthu.expression.function.indicator.MacdFunction;
import org.amuthu.expression.function.indicator.MacdSignalFunction;
import org.amuthu.expression.function.indicator.MaxFunction;
import org.amuthu.expression.function.indicator.MfiFunction;
import org.amuthu.expression.function.indicator.MinFunction;
import org.amuthu.expression.function.indicator.MinusDirectionalIndexFunction;
import org.amuthu.expression.function.indicator.ObvFunction;
import org.amuthu.expression.function.indicator.PPOFunction;
import org.amuthu.expression.function.indicator.PlusDirectionalIndexFunction;
import org.amuthu.expression.function.indicator.ROCFunction;
import org.amuthu.expression.function.indicator.RangeFunction;
import org.amuthu.expression.function.indicator.RsiFunction;
import org.amuthu.expression.function.indicator.SarFunction;
import org.amuthu.expression.function.indicator.SmaFunction;
import org.amuthu.expression.function.indicator.StochDFunction;
import org.amuthu.expression.function.indicator.StochKFunction;

/**
 *
 * @author prabhu
 */
public class FunctionManager
{
   private HashMap<String, FunctionEvaluator> functionTable;
   private static FunctionManager instance;

   public static FunctionManager getInst()
   {
      if (instance == null)
      {
         instance = new FunctionManager();
      }
      return instance;
   }

   private FunctionManager()
   {
      functionTable = new HashMap<String, FunctionEvaluator>();
      initTable();
   }

   public FunctionEvaluator getEvaluator(String functionName)
   {
      return functionTable.get(functionName);
   }

   private void initTable()
   {
      functionTable.put("abs", new AbsFunction());
      functionTable.put("cos", new CosineFunction());
      functionTable.put("exp", new ExponentialFunction());
      functionTable.put("log", new LogarithmFunction());
      functionTable.put("rand", new RandomFunction());
      functionTable.put("sin", new SineFunction());
      functionTable.put("sqrt", new SqrtFunction());
      functionTable.put("lag", new LagFunction());

      functionTable.put("sma", new SmaFunction());
      functionTable.put("rsi", new RsiFunction());
      functionTable.put("adx", new AverageDirectionalIndexFunction());
      functionTable.put("bollinger_lower", new BollingerLowerFunction());
      functionTable.put("bollinger_upper", new BollingerUpperFunction());
      functionTable.put("bollinger_middle", new BollingerMiddleFunction());
      functionTable.put("cci", new CommodityChannelIndexFunction());
      functionTable.put("ema", new EmaFunction());
      functionTable.put("macd", new MacdFunction());
      functionTable.put("macd_signal", new MacdSignalFunction());
      functionTable.put("min", new MinFunction());
      functionTable.put("max", new MaxFunction());
      functionTable.put("mdi", new MinusDirectionalIndexFunction());
      functionTable.put("pdi", new PlusDirectionalIndexFunction());
      functionTable.put("atr", new AtrFunction());
      functionTable.put("ad", new AdFunction());
      functionTable.put("aroon_down", new AroonDownFunction());
      functionTable.put("aroon_up", new AroonUpFunction());
      functionTable.put("mfi", new MfiFunction());
      functionTable.put("obv", new ObvFunction());
      functionTable.put("ppo", new PPOFunction());
      functionTable.put("roc", new ROCFunction());
      functionTable.put("sar", new SarFunction());
      functionTable.put("stochk", new StochKFunction());
      functionTable.put("stochd", new StochDFunction());
      functionTable.put("range", new RangeFunction());
   }

}
